/**
 * @(#) ModuleFacade.as 
 *
 * @date		2009. 02. 04.
 * @version		1.0
 * @author		Shin, Yunwoo
 * @description	Application Facade
 * 				mvc간 주고 받는 메세지를 정의하고,  command를 등록한다. 
 */
package com.skt.common_hr.myprofile_sac
{
	import com.skt.common_hr.common.puremvc.CommonFacade;
	import com.skt.common_hr.myprofile_sac.controller.StartupCommand;
	
	import flash.display.DisplayObject;
	
	import org.puremvc.as3.multicore.interfaces.IFacade;
	
	public class MyProfileFacade extends CommonFacade 
	{

		//--------------------------------------
		//  messages
		//--------------------------------------
	
		// My Profile Messages 
		public static const STARTUP:String 						= 'startup';
		public static const CLOSE_MODULE:String					= 'closeModule';
		public static const LOAD_PROFILE_COMPLETE:String		= "loadProfileComplete";
		public static const LOAD_PROFILE_FAILED:String			= "loadProfileFailed";
		public static const LOAD_PROFILE_DETAIL_COMPLETE:String	= "loadProfileDetailComplete";
		public static const LOAD_PROFILE_DETAIL_FAILED:String	= "loadProfileDetailFailed";
		public static const LOAD_PHONES_COMPLETE:String			= "loadPhonesComplete";
		public static const LOAD_PHONES_FAILED:String			= "loadPhonesFailed";
		public static const SAVE_PHONES_COMPLETE:String			= "savePhonesComplete";
		public static const SAVE_PHONES_FAILED:String			= "savePhonesFailed";
		public static const LOAD_PROFILEDETAIL_COMPLETE:String	= "loadProfileDetailComplete";
		public static const LOAD_PROFILEDETAIL_FAILED:String	= "loadProfileDetailFailed";
		public static const LOAD_POST_COMPLETE:String			= "loadPostComplete";
		public static const LOAD_POST_FAILED:String				= "loadPostFailed";
		public static const SAVE_ADDRESS_COMPLETE:String		= "saveAddressComplete";
		public static const SAVE_ADDRESS_FAILED:String			= "saveAdressFailed";
		
		public static const CANCEL_ADDRESS_INPUT:String			= "canelAddressInput";
		public static const OK_ADDRESS_INPUT:String				= "okAddressInput";

		public function MyProfileFacade( key:String )
		{
			super(key);	
		}
		
        /**
         * Singleton ApplicationFacade Factory Method
         */
        public static function getInstance( key:String ) : MyProfileFacade 
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ] = new MyProfileFacade( key );
            return instanceMap[ key ] as MyProfileFacade;
        }

        /**
         * Register Commands with the Controller 
         *     - parent 클래스의 생성자에서 자동으로 호출됨
         */
        override protected function initializeController( ) : void {
            super.initializeController();            
            registerCommand(STARTUP, StartupCommand);
        }
       
        /**
         * Module의 시작점으로 MyProfile.mxml의 creationComplete 이벤트에서 호출한다.
         *     
         */
        public function startup(app:Object) :void 
        {
        	//trace("send startup in MyProfile");
        	this.app = app as DisplayObject;
            sendNotification( STARTUP, app );
        }
	}
}